<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 头部操作栏 -->
            <form class="layui-form">
                 <div class="layui-form lay-header">
                <div class="toolbar">
                    <div class="layui-form-item lay-query-content">
                        <div class="lay-query-box">
                            <div class="query-lt">
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">作业单编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="code" class="layui-input" type="text" placeholder="作业单编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">计划单编号：</label>
                                    <div class="layui-input-inline">
                                        <input name="planCode" class="layui-input" type="text" placeholder="计划单编号"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">发货仓：</label>
                                    <div class="layui-input-inline">
                                        <select name="outWarehouseId">
                                        </select>
                                    </div>
                                </div>
                                <!--<div class="layui-inline">
                                    <label class="layui-form-label w-auto">收货仓：</label>
                                    <div class="layui-input-inline">
                                        <select name="inWarehouseId" lay-filter="inWarehouseId"
                                                id="inWarehouseNameSelect">
                                            <option value="">收货仓</option>
                                        </select>
                                    </div>
                                </div>-->
                                <!--<div class="layui-inline">
                                    <label class="layui-form-label w-auto">商品名称：</label>
                                    <div class="layui-input-inline">
                                        <input name="productName" class="layui-input" type="text" placeholder="商品名称"/>
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">商品编码：</label>
                                    <div class="layui-input-inline">
                                        <input name="skuCode" class="layui-input" type="text" placeholder="商品编码"/>
                                    </div>
                                </div>-->
                                <div class="layui-inline">
                                    <label class="layui-form-label w-auto">创建时间：</label>
                                    <div class="layui-input-inline">
                                        <input  id="pTime" class="layui-input date-icon" type="text"
                                               placeholder="选择创建时间" autocomplete="off"/>
                                    </div>
                                    <input name="startCreateTime" id="sTime" type="hidden" style="display:none"/>
                                    <input name="endCreateTime" id="eTime" type="hidden" style="display:none"/>
                                </div>
                            </div>
                            <div class="query-rt">
                                <div class="layui-inline">
                                    <button type="button" class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog"
                                            lay-submit>查询
                                    </button>
                                    <button type="reset" class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>重置
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="lay-btn-rows">
                    <div class="lay-btn-box">
                        <div class="lay-btn-lt">
                            <button type="button"  id="inventoryNewOutWorkRecordAdd" class="layui-btn icon-btn color-reseda">添加出库发货作业
                            </button>
                        </div>
                        <div class="lay-btn-rt">
                        </div>
                    </div>
                </div>
            </div>
            </form>
            <!-- 表格 -->
            <table class="layui-table" id="inventoryNewOutWorkRecordTable"
                   lay-filter="inventoryNewOutWorkRecordTable"></table>
        </div>
    </div>
</div>

<style>
    .inventoryNewOutWorkRecordAddForm .layui-form-label {
        width: 100px;
    }

    .inventoryNewOutWorkRecordAddForm .layui-input-inline {
        width: 230px;
    }

    .inventoryNewOutWorkRecordAddForm .layui-table-cell,
    .inventoryNewOutWorkRecordDetailFormCalss .layui-table-cell {
        height: auto;
    }

    .inventoryNewOutWorkRecordDetailFormCalss .open-details-box {
        padding: 20px;
    }

    .inventoryNewOutWorkRecordDetailFormCalss .open-details-box input {
        border: none !important;
        color: #666;
        width: auto;
    }

    .inventoryNewOutWorkRecordDetailFormCalss .layui-form-label {
        width: 90px;
    }
</style>

<script type="text/html" id="inventoryNewOutWorkRecordTableBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>
</script>

<!--商品操作按钮-->
<script type="text/html" id="inventoryAddProductBottomTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="add">添加出库信息</a>
</script>

<script type="text/html" id="workDeliverGoodsInfoTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="add">添加出库信息</a>
</script>

<script type="text/html" id="outStorageProductInfoDetailTableBar">
    <a class="layui-btn layui-btn-xs" lay-event="detail">明细</a>
</script>

<!--条码操作按钮-->
<script type="text/html" id="inventoryAddLabelCodeTableBar">
    {{# if(d.statusType=="created"){  }}
    <a class="layui-btn layui-btn-xs" lay-event="save">保存</a>
    {{# }else if(d.statusType =="save"){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="edit">修改</a>
    {{# } }}
</script>

<!--添加出库作业-->
<script type="text/html" id="inventoryNewOutWorkRecordAddForm">
    <form lay-filter="inventoryNewOutWorkRecordAddForm"
          class="layui-form open-form inventoryNewOutWorkRecordAddForm">
        <div class="open-model">
            <div class="open-auto">
                <input type="hidden" name="planId">
                <input type="hidden" name="outWarehouseId">
                <!-- 目标仓库名称-->
                <input type="hidden" name="inWarehouseName">
                <div class="layui-form-item">
                    <label class="layui-form-label">调拨出库计划</label>
                    <div class="layui-input-inline">
                        <input name="planCode" type="text" class="layui-input" readonly="readonly" lay-verify="required"
                               required/>
                    </div>
                    <a class="layui-btn" id="selectInventoryOutPlan">选择调拨出库计划</a>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">计划出库类型</label>
                    <div class="layui-input-inline">
                        <input name="inoutTypeName" type="text" class="layui-input" readonly="readonly"/>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label">出库计划备注</label>
                    <div class="layui-input-inline">
                        <input name="planRemark" type="text" class="layui-input" readonly="readonly"/>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">出库仓库</label>
                    <div class="layui-input-inline">
                        <input name="outWarehouseName" type="text" class="layui-input" readonly="readonly"/>
                    </div>
                </div>
                <div class="layui-form-item noShippingPlan" style="display: none;">
                    <label class="layui-form-label">选择目标仓库</label>
                    <div class="layui-input-inline">
                        <select name="province" id="province" lay-filter="province">
                            <option value="">请选择省</option>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="city" id="city" lay-filter="city">
                            <option value="">请选择市</option>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="inWarehouseId" id="inWarehouseId" lay-filter="inWarehouseId" lay-verify="required"
                                required>
                            <option value="">选择仓库</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item isShippingPlan" style="display: none;">
                    <label class="layui-form-label">目标柜子</label>
                    <div class="layui-input-inline">
                        <input name="cabinetName" type="text" class="layui-input" readonly="readonly"/>
                    </div>
                </div>
                <div class="layui-form-item table-bor">
                    <label class="layui-form-label" style="padding-top: 23px;">发货商品信息</label>
                    <div class="layui-input-block" style="margin-left: 130px;">
                        <table class="layui-table" id="workDeliverGoodsInfoTable"
                               lay-filter="workDeliverGoodsInfoTable"></table>
                    </div>
                </div>
                <div class="layui-form-item noShippingPlan" style="display: none;">
                    <label class="layui-form-label">运输方式</label>
                    <div class="layui-input-inline">
                        <select name="transportType" id="transportType" lay-filter="transportType" lay-verify="required"
                                required>
                            <option value="">请选择运输方式</option>
                            <option value="logistics">物流运输</option>
                            <option value="express">快递运输</option>
                            <option value="self">自行运输</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item isLogistics" style="display: none;">
                    <label class="layui-form-label">物流企业</label>
                    <div class="layui-input-inline">
                        <select name="companyId" id="companyId" lay-filter="companyId">
                            <option value="">请选择物流企业</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item isLogistics" style="display: none;">
                    <label class="layui-form-label">物流单号</label>
                    <div class="layui-input-inline">
                        <input name="expressCode" type="text" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item isSelf" style="display: none;">
                    <label class="layui-form-label">车牌号</label>
                    <div class="layui-input-inline">
                        <input name="carNo" type="text" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item isSelf" style="display: none;">
                    <label class="layui-form-label">联系人</label>
                    <div class="layui-input-inline">
                        <input name="customerConcat" type="text" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item isSelf" style="display: none;">
                    <label class="layui-form-label">电话</label>
                    <div class="layui-input-inline">
                        <input name="customerMoble" type="text" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">出库作业描述</label>
                    <div class="layui-input-inline">
                        <input name="remark" type="text" class="layui-input">
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                <button class="layui-btn" lay-filter="inventoryNewOutWorkRecordFormSubmit" lay-submit>保存</button>
            </div>
        </div>
    </form>
</script>

<!--添加商品信息-->
<script type="text/html" id="inventoryAddProductForm">
    <form lay-filter="inventoryAddProductForm" class="layui-form model-form model-scroll" style="padding-top: 0;">
        <div class="open-details-box table-bor" style="padding: 0 20px;">
            <div class="layui-form-item">
                <table class="layui-table" id="inventoryAddProductTopTable"
                       lay-filter="inventoryAddProductTopTable"></table>
            </div>
            <div class="layui-form-item scroll-table-4">
                <table class="layui-table" id="inventoryAddProductBottomTable"
                       lay-filter="inventoryAddProductBottomTable"></table>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="inventoryAddProductFormFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!--添加调拨出库包装码-->
<script type="text/html" id="inventoryAddLabelCodeForm">
    <form lay-filter="inventoryAddLabelCodeForm" class="layui-form model-form model-scroll">
        <div class="open-details-box" style="padding: 0 20px;">
            <div class="layui-form-item">
                <label class="layui-form-label w-auto">包装条码</label>
                <div class="layui-input-inline" style="width: 260px;">
                    <input name="outStorageWorkLabelCode" type="text" class="layui-input workBinCode"
                           placeholder="请输入包装条码"/>
                </div>
                <div class="layui-input-inline">
                    <button class="layui-btn icon-btn color-green" id="outStorageWorkLabelCodeConfig"
                       style="padding: 0 18px;">确定</button>
                </div>
            </div>
            <div class="layui-form-item table-bor scroll-table-5">
                <table class="layui-table" id="inventoryAddLabelCodeTable"
                       lay-filter="inventoryAddLabelCodeTable"></table>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            <button class="layui-btn" lay-filter="inventoryAddLabelCodeFormSubmit" lay-submit>保存</button>
        </div>
    </form>
</script>

<!-- 选择出库计划编号 -->
<script type="text/html" id="selectInventoryOutPlanListForm">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form toolbar">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label w-auto">出库单编号：</label>
                            <div class="layui-input-inline mr0">
                                <input name="code" class="layui-input" type="text" placeholder="出库单编号"/>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="selectInventoryOutPlanListFormSearchLog"
                                    lay-submit>搜索
                            </button>
                            <button id="selectInventoryOutPlanListClose" class="layui-btn icon-btn">确认选择</button>
                        </div>
                    </div>
                </div>

                <!-- 表格 -->
                <table class="layui-table" id="selectInventoryOutPlanListTable"
                       lay-filter="selectInventoryOutPlanListTable"></table>
            </div>
        </div>
    </div>
</script>

<!--详情弹窗-->
<script type="text/html" id="inventoryNewOutWorkRecordDetailForm">
    <form lay-filter="inventoryNewOutWorkRecordDetailForm"
          class="layui-form open-form inventoryNewOutWorkRecordDetailFormCalss">
        <div class="open-model">
            <div class="open-auto">
                <div class="layui-row">
                    <div class="layui-col-md5">
                        <div class="layui-form-item">
                            <div class="open-details-title">单据信息</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">出库作业单号</label>
                            <div class="layui-input-inline">
                                <input name="code" type="text" class="layui-input text-red" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">出库类型</label>
                            <div class="layui-input-inline">
                                <input name="inoutTypeName" type="text" class="layui-input text-red" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">所属出库计划</label>
                            <div class="layui-input-inline">
                                <input name="planCode" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">发货仓库</label>
                            <div class="layui-input-inline">
                                <input name="outWarehouseName" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">入库仓库</label>
                            <div class="layui-input-inline" style="width: 390px">
                                <input name="inWarehouseName" type="text" class="layui-input" readonly="readonly" style="width: 100%;"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">操作人</label>
                            <div class="layui-input-inline">
                                <input name="creatorName" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">备注</label>
                            <div class="layui-input-inline">
                                <input name="remark" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md5 layui-col-md-offset2">
                        <div class="layui-form-item">
                            <div class="open-details-title">物流信息</div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">运输方式</label>
                            <div class="layui-input-inline">
                                <input name="transportTypeDesc" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item detailIsLogistics" style="display: none;">
                            <label class="layui-form-label">物流企业</label>
                            <div class="layui-input-inline">
                                <input name="logisticsCompany" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item detailIsLogistics" style="display: none;">
                            <label class="layui-form-label">物流单号</label>
                            <div class="layui-input-inline">
                                <input name="expressCode" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item detailIsSelf" style="display: none;">
                            <label class="layui-form-label">车牌号</label>
                            <div class="layui-input-inline">
                                <input name="carNo" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item detailIsSelf" style="display: none;">
                            <label class="layui-form-label">电话</label>
                            <div class="layui-input-inline">
                                <input name="customerMoble" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item detailIsSelf" style="display: none;">
                            <label class="layui-form-label">联系人</label>
                            <div class="layui-input-inline">
                                <input name="customerConcat" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">操作时间</label>
                            <div class="layui-input-inline">
                                <input name="createTime" type="text" class="layui-input" readonly="readonly"/>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="layui-row table-bor">
                    <div class="open-details-title">出库物料信息</div>
                    <table class="layui-table" id="outStorageProductInfoDetailTable"
                           lay-filter="outStorageProductInfoDetailTable"></table>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            </div>
        </div>
    </form>
</script>

<!--详情包装码明细-->
<script type="text/html" id="inventoryNewOutWorkRecordLabelDetailForm">
    <form lay-filter="inventoryNewOutWorkRecordLabelDetailForm"
          class="layui-form open-form inventoryNewOutWorkRecordDetailFormCalss">
        <div class="open-model">
            <div class="open-auto">
                <div class="layui-form-item table-bor">
                    <table class="layui-table" id="detailSkuProductTable"
                           lay-filter="detailSkuProductTable"></table>
                </div>

                <div class="layui-form-item table-bor">
                    <table class="layui-table" id="detailSkuProductInLabelTable"
                           lay-filter="detailSkuProductInLabelTable"></table>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
            </div>
        </div>
    </form>
</script>

<!-- js部分 -->
<script>
    layui.use(['layer', 'form', 'table', 'admin', 'laydate', 'upload'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var table = layui.table;
        var config = layui.config;
        var admin = layui.admin;
        var upload = layui.upload;
        var laydate = layui.laydate;
        var boxGoodsLabel = []; // 料箱层级缓存数据

        //时间范围
        laydate.render({
            elem: '#pTime',
            type: 'date',
            range: true,
            done: function (value, date, endDate) {
                if(value){
                    let dateValue = value.split(" - ");
                    $("input[name='startCreateTime']").val(dateValue[0] + " 00:00:00");
                    $("input[name='endCreateTime']").val(dateValue[1] + " 23:59:59");
                }else {
                    $("input[name='startCreateTime']").val("");
                    $("input[name='endCreateTime']").val("");
                }
            }
        });
        // option渲染
        function loadSelectHtml(data, tips, htmltarget, type) {
            let html = ' <option value>' + tips + '</option>';
            if (!data || data == null) {
                return;
            }
            for (let i = 0; i < data.length; i++) {
                if (type == 1) {
                    html += `<option value='${data[i].productType}'>${data[i].name}</option>`;
                } else if (type == 2) {
                    html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                } else if (type == 3) {
                    html += `<option value='${data[i].id}'>${data[i].warehouseName}</option>`;
                }else if(type == 4){
                    html += `<option value='${data[i].skuCode}'  skuCode='${data[i].skuCode}'>${data[i].skuName}</option>`;
                } else if(type == 5){
                    html += `<option value='${data[i].skuCode}'>${data[i].skuName}</option>`;
                } else if(type == 6){
                    html += `<option value='${data[i].code}'>${data[i].name}</option>`;
                }

            }

            $("form select[name='" + htmltarget + "']").html(html);
            form.render('select');
        }


        //查询仓库
        admin.req('enterprisecab/warehouse/admin/warehouse/getWarehouseVOAll', {}, function (res) {
            if (res.code == 200) {
                if (res.data.length > 0){
                    loadSelectHtml(res.data, "选择仓库", "outWarehouseId", 2);
                }
            } else {
                layer.msg(res.msg, {icon: 2});
            }
        }, 'GET');

        // 渲染表格
        var insTb = table.render({
            elem: '#inventoryNewOutWorkRecordTable',
            url: config.base + 'enterprisecab/order/admin/inventoryNewOutWorkRecord/list',
            page: true,
            cellMinWidth: 100,
            cols: [[
                {type: 'checkbox'}
                , {field: 'code', sort: true, title: '出库作业单编号', width: 150}
                , {field: 'planCode',title: '所属出库计划', width: 150}
                , {field: 'consigner', title: '发货人'}
                , {field: 'quantityTotal',title: '出库商品数量'}
                , {field: 'marketAmount', title: '市场总价'}
                , {field: 'supplyAmount', title: '总供货金额'}
                , {field: 'outWarehouseName',title: '出库仓库'}
                , {field: 'customerConcat', title: '收货人'}
                , {field: 'inAreaName', title: '仓库所在地'}
                , {field: 'createTime', sort: true, title: '添加时间'}
                , {align: 'center', toolbar: '#inventoryNewOutWorkRecordTableBar', title: '操作', width: 160}
            ]],
            done: function (res, curr, count) {

            }
        });

        // 工具条点击事件
        table.on('tool(inventoryNewOutWorkRecordTable)', function (obj) {
            var data = obj.data;
            if (obj.event === 'detail') { //详情
                showDetailModel(data);
            }
        });

        //监听排序
        table.on('sort(inventoryNewOutWorkRecordTable)', function (obj) {
            table.reload('inventoryNewOutWorkRecordTable', {
                initSort: obj
                , where: {
                    sort: obj.field
                    , order: obj.type
                }
            });
        });

        // 搜索
        form.on('submit(formSubSearchLog)', function (data) {
            insTb.reload({where: data.field, page: {curr: 1}}, 'data');
        });

        //渲染下拉框
        form.render('select');

        $("#inventoryNewOutWorkRecordAdd").click(function () {
            inventoryNewOutWorkRecordAddModel();
        })

        // 添加出库发货作业记录
        function inventoryNewOutWorkRecordAddModel() {
            var addWorkDialog = admin.open({
                type: 1,
                area: ['82%', '90%'],
                offset: '65px',
                title: '添加出库发货作业记录',
                content: $('#inventoryNewOutWorkRecordAddForm').html(),
                success: function () {
                    let workGoodsData = [];
                    // 选择出库计划
                    $("#selectInventoryOutPlan").click(function () {
                        selectInventoryOutPlanModel();
                    })

                    // 发货商品信息
                    var workDeliverGoodsInfoTable = table.render({
                        elem: '#workDeliverGoodsInfoTable',
                        data: workGoodsData,
                        cellMinWidth: 100,
                        cols: [[
                            {title: '序号', width: 60, type: 'numbers', align: 'center'}
                            , {field: 'skuCode', title: '物料编号', width: 150, align: 'center'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: (d) => "<img src='" + d.skuPic + "' width='80px' height='80px'/>",
                                align: 'center'
                            }
                            , {field: 'productName', title: '物料名称', align: 'center'}
                            , {field: 'skuSpecCode', title: '规格', align: 'center'}
                            , {field: 'enterpriceCode', title: '企业货号', align: 'center'}
                            , {field: 'supplyPriceTotal', title: '平台结算价', align: 'center'}
                            , {field: 'quantityOut', title: '出库数量', align: 'center'}
                            , {field: 'unitName', title: '单位', align: 'center'}
                            , {field: 'marketPriceTotal', title: '总金额', align: 'center'}
                            , {field: 'quantity', title: '计划出库数', align: 'center'}
                            , {align: 'center', toolbar: '#workDeliverGoodsInfoTableBar', title: '操作'}
                        ]]
                    });

                    // 工具条点击事件
                    table.on('tool(workDeliverGoodsInfoTable)', function (obj) {
                        let data = obj.data;
                        let warehouseId = $("input[name='outWarehouseId']").val();
                        if (obj.event === 'add') { //添加商品
                            inventoryAddProductModel(data, warehouseId, workGoodsData);
                        }
                    });

                    // 选择出库计划回显
                    window.valueOutPlanModel = function (dataS) {
                        $("input[name='planId']").val(dataS.id);
                        $("input[name='planCode']").val(dataS.code);
                        $("input[name='planRemark']").val(dataS.remark);
                        $("input[name='inoutTypeName']").val(dataS.inoutTypeName);
                        $("input[name='outWarehouseName']").val(dataS.outWarehouseName);
                        $("input[name='inWarehouseName']").val(dataS.inWarehouseName);
                        $("input[name='outWarehouseId']").val(dataS.outWarehouseId);
                        $("input[name='cabinetName']").val(dataS.cabinetName);
                        // 如果计划选择的是调拨至刀柜
                        if (dataS.inoutTypeCode == 'shippingPlan') {
                            $(".isShippingPlan").show();
                            $(".noShippingPlan").hide();
                            $(".isSelf").find('input').attr('lay-verify', 'none');
                            $(".isLogistics").find('input').attr('lay-verify', 'none');
                            $(".noShippingPlan").find('select').attr('lay-verify', 'none');
                        } else {
                            // 如果 调拨到云仓入库 就查平台端仓库接口否则企业端仓库接口
                            let url = '';
                            if (dataS.inoutTypeCode == 'allotCloudWarehouse') {
                                url = 'enterprisecab/warehouse/admin/warehouse/getPlatformWarehouseAll'
                            } else {
                                url = 'enterprisecab/warehouse/admin/warehouse/getWarehouseVOAll'
                            }
                            $(".noShippingPlan").find('select').attr('lay-verify', 'required');

                            // 请求省份
                            admin.reqSync('enterprisecab/area/admin/area/getProvince', {}, function (res) {
                                if (200 == res.code) {
                                    loadSelectHtml(res.data, "请选择省份", "province", 2);
                                }else {
                                    loadSelectHtml([], "请选择省份", "province", 2);
                                }
                            }, 'GET');


                            // 请求城市
                            if(dataS.province === 0){
                                loadSelectHtml([], "请选择城市", "city", 2);
                            }else {
                                admin.reqSync('enterprisecab/area/admin/area/getCity',{parentId:dataS.province}, function (res) {
                                    if (200 == res.code) {
                                        loadSelectHtml(res.data, "请选择城市", "city", 2);
                                    }else {
                                        loadSelectHtml([], "请选择城市", "city", 2);
                                    }
                                }, 'GET');
                            }



                            // 查询目标仓库
                            admin.reqSync(url, {parentId:dataS.province,city:dataS.city}, function (res) {
                                if (200 == res.code) {
                                    loadSelectHtml(res.data, "请选择厂库", "inWarehouseId", 2);
                                }else {
                                    loadSelectHtml([], "请选择厂库", "inWarehouseId", 2);
                                }
                               /* if (res.code == 200) {
                                    // 数据渲染
                                    $.each(res.data, function (index, item) {
                                        $("#inWarehouseId").append(new Option(item.name, item.id));
                                    })
                                    form.render('select');
                                    // 显示默认仓库
                                    let select = 'dd[lay-value=' + dataS.inWarehouseId + ']';
                                    $('#inWarehouseId').siblings("div.layui-form-select").find('dl').find(select).click();
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }*/
                            }, 'GET');
                            $(".isShippingPlan").hide();
                            $(".noShippingPlan").show();

                            // 省份下拉事件
                            form.on('select(province)', function (d) {
                                loadSelectHtml([], "请选择城市", "city", 2);
                                loadSelectHtml([], "请选择仓库", "inWarehouseId", 2);
                                if(d.value){
                                    admin.req('enterprisecab/area/admin/area/getCity',{parentId:d.value}, function (res) {
                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择城市", "city", 2);
                                        }
                                    }, 'GET', true);
                                }
                            });

                            // 城市下拉事件
                            form.on('select(city)', function (d) {
                                loadSelectHtml([], "请选择仓库", "inWarehouseId", 2);
                                if(d.value){
                                    admin.req(url,{parentId:$('#province').val(),city:d.value}, function (res) {
                                        if (200 == res.code) {
                                            loadSelectHtml(res.data, "请选择仓库", "inWarehouseId", 2);
                                        }
                                    }, 'GET', true);
                                }
                            });

                            $("#inWarehouseId").val(dataS.inWarehouseId);
                            $("#province").val(dataS.province);
                            $("#city").val(dataS.city);
                            form.render('select');

                        }

                        // 查询商品
                        getInventoryOutPlanDetailVOList(dataS.id);


                        // 选择目标仓库
                        form.on('select(inWarehouseId)', function (d) {
                            let elem = d.elem;
                            let textVal = elem[elem.selectedIndex].text;
                            $("input[name='inWarehouseName']").val(textVal);
                        });

                    }

                    // 查询出库计划商品
                    function getInventoryOutPlanDetailVOList(planId) {
                        admin.req('enterprisecab/order/admin/inventoryNewOutWorkRecord/getInventoryOutPlanDetailVOList', {planId: planId}, function (res) {
                            if (res.code == 200) {
                                workGoodsData = res.data;
                                workGoodsData.forEach((item, index) => {
                                    workGoodsData[index].quantityOut = 0;
                                    workGoodsData[index]['list'] = [];
                                })
                                // 渲染表格
                                table.reload('workDeliverGoodsInfoTable', {
                                    data: workGoodsData,
                                    limit: workGoodsData.length
                                });
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GET');
                    }

                    // 选择运输方式
                    form.on('select(transportType)', function (d) {
                        if (d.value == 'self') { //自行运输
                            $(".isSelf").show();
                            $(".isLogistics").hide();
                            $(".isSelf").find('input').attr('lay-verify', 'required');
                            $(".isLogistics").find('input').attr('lay-verify', 'none');
                            $(".isLogistics").find('select').attr('lay-verify', 'none');
                        } else { //物流运输
                            $(".isSelf").hide();
                            $(".isLogistics").show();
                            $(".isSelf").find('input').attr('lay-verify', 'none');
                            $(".isLogistics").find('input').attr('lay-verify', 'required');
                            $(".isLogistics").find('select').attr('lay-verify', 'required');
                            getLogisticsCompany();
                        }
                    });

                    // 获取物流企业
                    function getLogisticsCompany() {
                        admin.req('enterprise/invoicing/admin/transportCompany/getAll', {}, function (res) {
                            if (res.code == 200) {
                                // 数据渲染
                                $.each(res.data, function (index, item) {
                                    $("#companyId").append(new Option(item.name, item.id));
                                })
                                form.render('select');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GET');
                    }

                    //渲染下拉框
                    form.render('select');

                    // 子页面保存返回的本地数据
                    window.valueProductJobLabelList = function (saveData) {
                        workGoodsData.forEach((item, index) => {
                            if (saveData.productId == item.id) {
                                workGoodsData[index]['list'] = saveData.jobLabelList;
                                let num = 0;
                                item.list.forEach((ele, idx) => {
                                    num += parseInt(ele.quantityOut);
                                    workGoodsData[index].quantityOut = num
                                })
                            }
                        });

                        table.reload('workDeliverGoodsInfoTable', {
                            data: workGoodsData,
                            limit: workGoodsData.length
                        });
                    }

                    // 表单提交
                    form.on('submit(inventoryNewOutWorkRecordFormSubmit)', function (d) {
                        let detailList = [];
                        let jobLabelList = [];
                        workGoodsData.forEach((item, index) => {
                            if(item.quantityOut > 0) {
                                detailList.push({
                                    skuCode: item.skuCode,
                                    skuPic: item.skuPic,
                                    productName: item.productName,
                                    skuSpecCode: item.skuSpecCode,
                                    unitName: item.unitName,
                                    unitId: item.unitId,
                                    marketPrice: item.marketPrice,
                                    barcode: item.barcode,
                                    enterpriceCode: item.enterpriceCode,
                                    supplyPrice: item.supplyPrice,
                                    quantityOut: item.quantityOut,
                                    id: item.id,
                                });
                                if (item.list.length > 0) {
                                    item.list.forEach((ele, idx) => {
                                        jobLabelList.push({
                                            packLabeId: ele.packLabeId,
                                            code: ele.code,
                                            packId: ele.packId,
                                            packName: ele.packName,
                                            skuCode: ele.skuCode,
                                            boxCode: ele.boxCode,
                                            quantityOut: ele.quantityOut,
                                            quantity: ele.quantity,
                                            warehouseId: ele.warehouseId,
                                        })
                                    })
                                }
                            }
                        });
                        if (jobLabelList.length == 0) {
                            layer.msg('请添加出库商品信息', {icon: 2});
                            return false;
                        }

                        let paramData = {
                            ...d.field,
                            jobLabelList: jobLabelList,
                            detailList: detailList,
                        }
                        layer.load(2);
                        admin.req('enterprisecab/order/admin/inventoryNewOutWorkRecord/addOutWork', JSON.stringify(paramData), function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                layer.msg(res.msg, {icon: 1});
                                table.reload('inventoryNewOutWorkRecordTable');
                                layer.close(addWorkDialog);
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'POST', true, 'application/json; charset=utf-8');
                        return false;
                    });
                }
            });
        }

        // 选择出库计划
        function selectInventoryOutPlanModel() {
            var outPlanModel = admin.open({
                type: 1,
                area: ['78%', '840px'],
                offset: '65px',
                title: '调拨出库计划',
                content: $('#selectInventoryOutPlanListForm').html(),
                success: function () {
                    // 渲染表格
                    var selectInventoryOutPlanListTable = table.render({
                        elem: '#selectInventoryOutPlanListTable',
                        url: config.base + 'enterprisecab/order/admin/inventoryOutPlan/list',
                        where: {status: 'confirm'},
                        page: true,
                        cellMinWidth: 100,
                        cols: [[
                            {type: 'radio'}
                            , {field: 'code', sort: true, title: '出库计划单编号', width: 150}
                            , {field: 'outWarehouseName', sort: true, title: '发货仓库'}
                            , {field: 'consigner', sort: true, title: '发货人'}
                            , {field: 'quantityTotal', sort: true, title: '出库商品数量', width: 150}
                            , {field: 'marketAmount', sort: true, title: '市场总价', width: 120}
                            , {field: 'supplyAmount', sort: true, title: '总供货金额'}
                            , {field: 'inoutTypeName', title: '出库类型',width: 160}
                            , {field: 'inWarehouseName', sort: true, title: '入库云仓'}
                            , {field: 'inAreaName', sort: true, title: '仓库所在地'}
                            , {field: 'statusDesc', sort: true, title: '状态'}
                            , {field: 'createTime', title: '添加时间', width: 160}
                        ]],
                    });

                    // 搜索
                    form.on('submit(selectInventoryOutPlanListFormSearchLog)', function (data) {
                        selectInventoryOutPlanListTable.reload({where: data.field, page: {curr: 1}}, 'data');
                    });

                    // 确认选择
                    $('#selectInventoryOutPlanListClose').click(function () {
                        var checkStatus = table.checkStatus('selectInventoryOutPlanListTable'); //test即为基础参数id对应的值
                        var dataS = checkStatus.data;

                        if (checkStatus.data.length == 0) {
                            layer.msg("请选择出库作业单", {icon: 2, time: 1000});
                        } else {
                            parent.valueOutPlanModel(dataS[0]);
                            layer.close(outPlanModel);
                        }
                    });
                }
            });
        }

        // 添加商品
        function inventoryAddProductModel(data, warehouseId, workGoodsData) {
            console.log(workGoodsData, 'workGoodsData');
            var productModel = admin.open({
                type: 1,
                area: ['77%', '840px'],
                offset: '65px',
                title: '添加出库商品信息',
                content: $('#inventoryAddProductForm').html(),
                success: function () {
                    let getOutWorkPalletBoxList = [];
                    // 料箱列表
                    var inventoryAddProductBottomTable = table.render({
                        elem: '#inventoryAddProductBottomTable',
                        data: getOutWorkPalletBoxList,
                        cellMinWidth: 100,
                        cols: [[
                            {title: '序号', width: 60, type: 'numbers', align: 'center'}
                            , {field: 'code', title: '料箱编码', width: 150, align: 'center'}
                            , {field: 'areaName', title: '所在库区', align: 'center'}
                            , {field: 'spaceCode', title: '所在货位', align: 'center'}
                            , {field: 'amountQuantity', title: '最小单位库存数', align: 'center'}
                            , {field: 'labelQuantity', title: '包装编码数', align: 'center'}
                            , {field: 'quantityOut', title: '发货数', align: 'center'}
                            , {align: 'center', toolbar: '#inventoryAddProductBottomTableBar', title: '操作', width: 160}
                        ]]
                    });

                    // 查询料箱
                    admin.req('enterprisecab/order/admin/inventoryNewOutWorkRecord/getOutWorkPalletBoxList', {
                        skuCode: data.skuCode,
                        warehouseId: warehouseId
                    }, function (res) {
                        if (res.code == 200) {
                            getOutWorkPalletBoxList = res.data;

                            // 仓库可发库存取料箱第一条
                            if (getOutWorkPalletBoxList.length > 0) {
                                data.warehouseQuantity = getOutWorkPalletBoxList[0].warehouseQuantity;
                            } else {
                                data.warehouseQuantity = 0;
                            }

                            // 拿出商品列表中的缓存数据
                            let _boxGoodsLabelData = data.list;

                            // 通过商品列表中的缓存数据判断是否添加过料箱条码 添加过则回显数量 否则显示0
                            if (_boxGoodsLabelData.length > 0 && getOutWorkPalletBoxList.length > 0) {
                                // 循环出相同料箱的数据
                                for (let i = 0; i < getOutWorkPalletBoxList.length; i++) {
                                    let listData = [];
                                    let arr1 = getOutWorkPalletBoxList[i];
                                    for (let k = 0; k < _boxGoodsLabelData.length; k++) {
                                        let arr2 = _boxGoodsLabelData[k];
                                        if (arr1.code == arr2.boxCode) {
                                            listData.push(arr2);
                                        }
                                    }
                                    getOutWorkPalletBoxList[i]['list'] = listData
                                }

                                // 数量累加->出库数量
                                getOutWorkPalletBoxList.forEach((item, index) => {
                                    let num = 0;
                                    if (item.list.length > 0) {
                                        item.list.forEach((ele, idx) => {
                                            num += parseInt(ele.quantityOut);
                                            getOutWorkPalletBoxList[index].quantityOut = num
                                        })
                                    } else {
                                        getOutWorkPalletBoxList[index].quantityOut = 0
                                    }
                                })

                            } else {
                                if (getOutWorkPalletBoxList.length > 0) {
                                    getOutWorkPalletBoxList.forEach((ele, idx) => {
                                        getOutWorkPalletBoxList[idx].quantityOut = 0;
                                        getOutWorkPalletBoxList[idx]['list'] = []
                                    });
                                }
                            }

                            // 渲染表格
                            table.reload('inventoryAddProductBottomTable', {
                                data: getOutWorkPalletBoxList,
                                limit: getOutWorkPalletBoxList.length
                            });
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET', false);

                    // 详情顶部表格
                    var inventoryAddProductTopTable = table.render({
                        elem: '#inventoryAddProductTopTable',
                        data: [data],
                        cellMinWidth: 100,
                        cols: [[
                            {field: 'productName', title: '物料名称', width: 150, align: 'center'}
                            , {field: 'unitName', title: '最小单位名称', align: 'center'}
                            , {field: 'quantity', title: '计划出库数量', align: 'center'}
                            , {field: 'warehouseQuantity', title: '仓库可发库存', align: 'center'}
                        ]]
                    });

                    // 工具条点击事件
                    table.on('tool(inventoryAddProductBottomTable)', function (obj) {
                        var data = obj.data;
                        if (obj.event === 'add') { // 添加
                            let boxCode = data.code;
                            let labelOldData = [];
                            getOutWorkPalletBoxList.forEach((item, index) => {
                                if (item.list.length > 0) {
                                    labelOldData.push(...item.list);
                                }
                            })
                            inventoryAddLabelCodeModel(workGoodsData, boxCode, labelOldData, data, warehouseId);
                        }
                    });

                    // 获取子页面包装条码数据
                    window.valueJobLabelList = function (valueSignMap) {
                        // 子页面带出添加的条码数据缓存本地
                        getOutWorkPalletBoxList.forEach((item, index) => {
                            if (valueSignMap.jobLabelList[0].boxCode == item.code) {
                                // 出库数量累加
                                getOutWorkPalletBoxList[index]['list'] = valueSignMap.jobLabelList;
                                let num = 0;
                                item.list.forEach((ele, idx) => {
                                    num += parseInt(ele.quantityOut);
                                    getOutWorkPalletBoxList[index].quantityOut = num
                                })
                            }
                        });
                        table.reload('inventoryAddProductBottomTable', {
                            data: getOutWorkPalletBoxList,
                            limit: getOutWorkPalletBoxList.length
                        });
                    }

                    // 添加出库商品页面缓存数据
                    form.on('submit(inventoryAddProductFormFormSubmit)', function () {
                        let jobLabelList = [];
                        getOutWorkPalletBoxList.forEach((item, index) => {
                            if (item.list.length > 0) {
                                jobLabelList.push(...item.list);
                            }
                        });
                        if (jobLabelList.length == 0) {
                            layer.msg('请添加出库条码信息', {icon: 2});
                            return false;
                        }
                        let paramData = {
                            productId: data.id,
                            jobLabelList: jobLabelList
                        }
                        $("#selectInventoryOutPlan").hide();
                        parent.valueProductJobLabelList(paramData);
                        layer.close(productModel);
                        return false;
                    });
                }
            });
        }

        // 添加包装码
        function inventoryAddLabelCodeModel(workGoodsData, boxCode, labelOldData, labelStorageData, warehouseId) {
            console.log(labelStorageData);
            var labelModel = admin.open({
                type: 1,
                area: ['75%', '845px'],
                offset: '65px',
                title: '添加出库商品信息',
                content: $('#inventoryAddLabelCodeForm').html(),
                success: function () {

                    // 去掉包装条码前后空格
                    $("input[name='outStorageWorkLabelCode']").blur(function() {
                        $(this).val($(this).val().trim())
                    });

                    let signLabelData = labelStorageData.list;
                    // 扫描条码
                    $("#outStorageWorkLabelCodeConfig").click(function () {
                        let code = $("input[name='outStorageWorkLabelCode']").val();
                        if (code == '') {
                            layer.msg('请输入物料编码', {icon: 2});
                            return false;
                        }

                        // 如果别的料箱扫了该包装码 则提示物料编码已存在
                        let filterLabel = labelOldData.filter((item) => {
                            return item.code == code;
                        });
                        let filterSign = signLabelData.filter((item) => {
                            return item.code == code;
                        });

                        if (filterLabel.length > 0 || filterSign.length > 0) {
                            layer.msg('物料编码已存在', {icon: 2});
                            return false;
                        }

                        layer.load(2);
                        admin.req('enterprise/product/admin/productPackLabel/getPackLabelVOByCode', {
                            code: code,
                            warehouseId: warehouseId,
                            type: '1'
                        }, function (res) {
                            layer.closeAll('loading');
                            if (res.code == 200) {
                                let rowData = res.data;
                                rowData.quantityOut = rowData.quantity;
                                rowData.statusType = 'created';
                                rowData.boxCode = boxCode;
                                rowData.warehouseId = warehouseId;
                                // 判断当前扫出来的条码skuCode是否出库计划条码
                                let skuList = workGoodsData.filter((item) => {
                                    return item.skuCode == res.data.skuCode;
                                });
                                if (skuList.length == 0) {
                                    layer.msg("当前条码不属于此出库计划条码", {icon: 2});
                                    return false;
                                }

                                signLabelData.push(rowData);

                                // 渲染表格
                                table.reload('inventoryAddLabelCodeTable', {
                                    data: signLabelData,
                                    limit: signLabelData.length
                                });
                                // 清空input
                                $("input[name='outStorageWorkLabelCode']").val('');
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }, 'GET', false);

                        return false;
                    });

                    // 包装码列表
                    var inventoryAddLabelCodeTable = table.render({
                        elem: '#inventoryAddLabelCodeTable',
                        data: signLabelData,
                        cellMinWidth: 100,
                        cols: [[
                            {title: '序号', width: 60, type: 'numbers'}
                            , {field: 'code', title: '包装编码', width: 150}
                            , {field: 'productName', title: '物料系列名称'}
                            , {field: 'packName', title: '包装规格'}
                            , {field: 'unitName', title: '最小单位'}
                            , {field: 'quantity', title: '单位包装数'}
                            , {field: 'quantity', title: '包装余数'}
                            , {
                                field: 'quantityOut', title: 'SN码签收数', align: 'center', templet: function (d) {
                                    if (d.statusType == 'save') {
                                        return '<span>' + d.quantityOut + '</span>'
                                    } else {
                                        return '<input signId="' + d.id + '" class="layui-input quantityOut" style="height: 28px;" type="text" ' +
                                            'value="' + d.quantityOut + '" />'
                                    }
                                }
                            }
                            , {align: 'center', toolbar: '#inventoryAddLabelCodeTableBar', title: '操作', width: 160}
                        ]]
                    });

                    // 监听签收数
                    $("body").delegate(".quantityOut", "change", function () {
                        let id = $(this).attr('signId');
                        let reg = /^[1-9]+[0-9]*$/;
                        let quantityOut = $(this).val();
                        signLabelData.forEach((item, index) => {
                            if ((item.id === id)) {
                                let quantity = parseInt(item.quantity);
                                if (!reg.test(quantityOut)) {
                                    layer.msg('请输入正确的数字', {icon: 2});
                                    quantityOut = quantity;
                                    $(this).val(quantityOut);
                                }
                                if (parseInt(quantityOut) > quantity) {
                                    layer.msg('签收数量不能大于包装余数', {icon: 2});
                                    return false;
                                }
                            }
                        })
                    });

                    // 工具条点击事件
                    table.on('tool(inventoryAddLabelCodeTable)', function (obj) {
                        let data = obj.data;
                        if (obj.event === 'save') { // 保存
                            let quantityOut = $(this).parents('td').siblings().find('.quantityOut').val(); //签收数
                            signLabelData.forEach((item, index) => {
                                if ((data.id === item.id)) {
                                    signLabelData[index].quantityOut = quantityOut;
                                    signLabelData[index].statusType = 'save';
                                }
                            });
                        } else if (obj.event === 'edit') { //修改
                            signLabelData.forEach((item, index) => {
                                if ((data.id === item.id)) {
                                    signLabelData[index].statusType = 'created';
                                }
                            });
                        }
                        // 渲染表格
                        table.reload('inventoryAddLabelCodeTable', {
                            data: signLabelData,
                            limit: signLabelData.length
                        });
                    });

                    // 缓存数据
                    form.on('submit(inventoryAddLabelCodeFormSubmit)', function () {
                        if (signLabelData.length == 0) {
                            layer.msg('出库商品不能为空', {icon: 2});
                            return false;
                        }
                        let filterList = signLabelData.filter((item) => {
                            return item.statusType == 'save';
                        });
                        if (filterList.length == 0) {
                            layer.msg("请保存出库商品", {icon: 2});
                            return false;
                        }
                        let paramData = {
                            jobLabelList: filterList
                        }
                        parent.valueJobLabelList(paramData);
                        layer.close(labelModel);
                        return false;
                    });
                }
            });
        }

        // 显示详情弹窗
        function showDetailModel(data) {
            admin.open({
                type: 1,
                area: ['1300px', '90%'],
                offset: '65px',
                title: '出库物料信息详情',
                content: $('#inventoryNewOutWorkRecordDetailForm').html(),
                success: function () {
                    if (data.transportType == 'self') {
                        $(".detailIsSelf").show();
                    } else {
                        $(".detailIsLogistics").show();
                    }
                    let storageProductArr = [];
                    // 查询入库商品信息
                    admin.req('enterprisecab/order/admin/inventoryNewOutWorkRecord/getOutWorkProductDetail', {jobId: data.id}, function (res) {
                        if (res.code == 200) {
                            storageProductArr = res.data;

                            table.reload('outStorageProductInfoDetailTable', {
                                data: storageProductArr,
                            })
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET');

                    var storageWorkProductDetailTable = table.render({
                        elem: '#outStorageProductInfoDetailTable',
                        data: storageProductArr,
                        cellMinWidth: 100,
                        cols: [[
                            {title: '序号', width: 60, type: 'numbers', align: 'center'}
                            , {field: 'skuCode', title: '物料编号', width: 150, align: 'center'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: (d) => "<img src='" + d.skuPic + "' width='80px' height='80px'/>",
                                align: 'center'
                            }
                            , {field: 'productName', title: '物料名称', align: 'center'}
                            , {field: 'skuSpecCode', title: '规格码', align: 'center'}
                            , {field: 'enterpriceCode', title: '企业货号', align: 'center'}
                            , {field: 'totalMoney', title: '平台结算价', align: 'center'}
                            , {field: 'quantity', title: '出库数量', align: 'center'}
                            , {field: 'unitName', title: '单位', align: 'center'}
                            , {field: 'totalMoney', title: '总金额', align: 'center'}
                            , {field: 'planQuantity', title: '计划出库数', align: 'center'}
                            , {align: 'center', toolbar: '#outStorageProductInfoDetailTableBar', title: '操作'}
                        ]]
                    });

                    // 工具条点击事件
                    table.on('tool(outStorageProductInfoDetailTable)', function (obj) {
                        let rowData = obj.data;
                        if (obj.event === 'detail') { //详情
                            showLabelDetailModel(rowData, data.id);
                        }
                    });

                    data.inWarehouseName = data.provinceName+"  "+data.cityName+"  "+data.inWarehouseName;
                    form.val('inventoryNewOutWorkRecordDetailForm', data);
                }
            });
        }

        // 详情的包装码明细
        function showLabelDetailModel(data, jobId) {
            admin.open({
                type: 1,
                area: ['75%', '90%'],
                offset: '65px',
                title: '出库物料明细详情',
                content: $('#inventoryNewOutWorkRecordLabelDetailForm').html(),
                success: function () {
                    let storageProductLabelArr = [];
                    // 查询入库条码
                    layer.load(2);
                    admin.req('enterprisecab/order/admin/inventoryNewOutWorkRecord/getOutWorkPackList', {
                        jobId: jobId,
                        jobProductId: data.jobProductId
                    }, function (res) {
                        layer.closeAll('loading');
                        if (res.code == 200) {
                            storageProductLabelArr = res.data;

                            table.reload('detailSkuProductInLabelTable', {
                                data: storageProductLabelArr,
                            })
                        } else {
                            layer.msg(res.msg, {icon: 2});
                        }
                    }, 'GET');

                    var detailSkuProductInLabelTable = table.render({
                        elem: '#detailSkuProductInLabelTable',
                        data: storageProductLabelArr,
                        cellMinWidth: 100,
                        cols: [[
                            {title: '序号', width: 60, type: 'numbers', align: 'center'}
                            , {field: 'packLabeCode', title: '包装编码', width: 150, align: 'center'}
                            , {field: 'productName', title: '物料名称', align: 'center'}
                            , {field: 'packName', title: '包装规格', align: 'center'}
                            , {field: 'unitName', title: '最小单位', align: 'center'}
                            , {field: 'quantity', title: '单位包装数', align: 'center'}
                            , {field: 'storageQuantity', title: '发货数', align: 'center'}
                        ]]
                    });

                    var detailSkuProductTable = table.render({
                        elem: '#detailSkuProductTable',
                        data: [data],
                        cellMinWidth: 100,
                        cols: [[
                            {field: 'skuCode', title: '物料编号', width: 150, align: 'center'}
                            , {
                                field: 'skuPic',
                                title: '图片',
                                templet: (d) => "<img src='" + d.skuPic + "' width='80px' height='80px'/>",
                                align: 'center'
                            }
                            , {field: 'productName', title: '物料名称', align: 'center'}
                            , {field: 'skuSpecCode', title: '规格', align: 'center'}
                            , {field: 'enterpriceCode', title: '企业货号', align: 'center'}
                            , {field: 'totalMoney', title: '平台结算价', align: 'center'}
                            , {field: 'quantity', title: '出库数量', align: 'center'}
                            , {field: 'unitName', title: '单位', align: 'center'}
                            , {field: 'totalMoney', title: '总金额', align: 'center'}
                            , {field: 'planQuantity', title: '计划出库数', align: 'center'}
                        ]]
                    });
                }
            });
        }
    });
</script>